home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / gate / RCS / Gate_ByNetAddr.c,v < prev    next >
Encoding:
Text File  |  1992-06-05  |  2.0 KB  |  92 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     92.06.04.22.03.20;  author jhh;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* 
  26.  * Gate_ByNetAddr.c --
  27.  *
  28.  *    Source code for the Gate_ByNetAddr library procedure.
  29.  *
  30.  * Copyright 1988 Regents of the University of California
  31.  * Permission to use, copy, modify, and distribute this
  32.  * software and its documentation for any purpose and without
  33.  * fee is hereby granted, provided that the above copyright
  34.  * notice appear in all copies.  The University of California
  35.  * makes no representations about the suitability of this
  36.  * software for any purpose.  It is provided "as is" without
  37.  * express or implied warranty.
  38.  */
  39.  
  40. #ifndef lint
  41. static char rcsid[] = "$Header: /user6/voelker/src/hosttest/RCS/Gate_ByNetAddr.c,v 1.1 92/03/26 19:44:07 voelker Exp Locker: voelker $ SPRITE (Berkeley)";
  42. #endif not lint
  43.  
  44. #include <stdio.h>
  45. #include <gate.h>
  46. #include <gateInt.h>
  47.  
  48.  
  49. /*
  50.  *-----------------------------------------------------------------------
  51.  *
  52.  * Gate_ByNetAddr --
  53.  *
  54.  *    Return information about the gateway with the given local network
  55.  *    address.
  56.  *
  57.  * Results:
  58.  *    A Gate_Entry structure describing the gateway.  If no such gateway
  59.  *    exists, NULL is returned.  The Gate_Entry is statically
  60.  *    allocated, and may be modified on the next call to any Gate_
  61.  *    procedure.
  62.  *
  63.  * Side Effects:
  64.  *    The gateway database is opened if it wasn't already.
  65.  *
  66.  *-----------------------------------------------------------------------
  67.  */
  68.  
  69. Gate_Entry *
  70. Gate_ByNetAddr(addrPtr)
  71.     Net_Address     *addrPtr;        /* Pointer to the address in the
  72.                      * format for the network */
  73. {
  74.     register Gate_Entry    *entry;
  75.     register int        i;
  76.     register unsigned char *address = (unsigned char *) addrPtr;
  77.  
  78.     if (Gate_Start() == 0) {
  79.     while (1) {
  80.         entry = Gate_Next();
  81.         if (entry == (Gate_Entry *) NULL) {
  82.         break;
  83.         }
  84.         if (!Net_AddrCmp(&entry->netAddr, addrPtr)) {
  85.         return entry;
  86.         }
  87.     }
  88.     }
  89.     return (Gate_Entry *) NULL;
  90. }
  91. @
  92.